Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatten migrations #1187

Merged
merged 10 commits into from
Aug 5, 2024
Merged

Flatten migrations #1187

merged 10 commits into from
Aug 5, 2024

Conversation

howard-e
Copy link
Contributor

@howard-e howard-e commented Aug 1, 2024

The migrations used in this project have grown as much as "deemed necessary" over the project's lifespan. This PR aims to remove those migrations and preserve the structure of the tables. Due to the suggested point for this PR's merge, there shouldn't be a need to preserve any functional changes of those previous migrations as all environments should be up to date migration-wise and the migrations were mostly focused on keeping up to date with changes to the application's code (from what I've gone through at least).

This should present a fresh start on the migrations by limiting the time taken to run them and also attempt to maintain the practice of, as best as possible to avoid using application code in any migration going forward.

@howard-e howard-e marked this pull request as ready for review August 5, 2024 13:28
@howard-e howard-e requested a review from stalgiag August 5, 2024 13:29
Copy link
Contributor

@stalgiag stalgiag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a terrific change! Left some minor comments. The main concern I would have is with continuing the migration after a failed backup dump.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reorganization is welcome! I am going to assume no functional changes. Let me know if this assumption is incorrect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to assume no functional changes

That's right!

const dumpTable = async tableName => {
try {
const dumpFilePath = path.resolve(
`${__dirname}/../dumps/dumpTable_${tableName}_${new Date().getTime()}.sql`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These files may eventually crowd directories on our local machines. It is easy enough to delete but just pointing this out. I don't think there is an action item here unless you want to add something to purge especially old ones.

Copy link
Contributor Author

@howard-e howard-e Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd rather this be left to each contributor to decide how to handle for themselves since they're gitignored. I suppose utils for clean:migrationDump:tables or clean:migrationDump:databases could be added but I don't think it's super necessary (to me)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! No need for a util for now.

await exec(
`pg_dump -t '"${tableName}"' ${process.env.PGDATABASE} --inserts > ${dumpFilePath}`
);
} catch (err) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to catch this? Might be safer to not run the migration if making the dump fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Addressed in 72861c2

Copy link
Contributor

@stalgiag stalgiag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks for addressing the comments.

@stalgiag stalgiag merged commit f9e90a5 into development Aug 5, 2024
2 checks passed
@stalgiag stalgiag deleted the flatten-migrations branch August 5, 2024 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants